package com.jwaoo.chat.session.avchat;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.dx.as.UI;
import com.jwaoo.chat.ChatHelpter;
import com.jwaoo.chat.R;
import com.jwaoo.media.dialog.EasyAlertDialog;

public class AVChatActivity extends UI {

    private static AVChatActivity avChatActivity;

    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        setContentView(FloatView.getInstance().getBaseView());
        avChatActivity = this;
        setToolbar(null);
        FloatView.getInstance().initWebRtc();
    }

    public static void startAVChatActivity(){
        Intent intent = new Intent(ChatHelpter.getContext(),AVChatActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        ChatHelpter.getContext().startActivity(intent);
    }

    public static void doHangUp(){
        if (avChatActivity != null){
            avChatActivity.finish();
            avChatActivity = null;
        }
    }

    @Override
    public void onBackPressed() {
        final EasyAlertDialog easyAlertDialog = new EasyAlertDialog(this);
        easyAlertDialog.setTitle("温馨提示:");
        easyAlertDialog.setMessage("您是要结束通话吗?");
        easyAlertDialog.addNegativeButton("确定", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FloatView.getInstance().onHangUpBtnClick();
            }
        });
        easyAlertDialog.addPositiveButton("取消", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                easyAlertDialog.dismiss();
            }
        });
        easyAlertDialog.show();
    }
}
